package netty.test22TcpSelfProto;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

/**
 * 执行的是入站操作，所以先从handler链表的 头部向尾部执行，所以下面的handler先执行
 * MyServerByteDecoder 再执行 MyServerHandler
 */
public class MySPServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        ChannelPipeline pipeline = socketChannel.pipeline();
        System.out.println("init channel ---->");
        pipeline.addLast(new MyMessageDecoder());
        pipeline.addLast(new MyMessageEncoder());
        pipeline.addLast(new MySPServerHandler());

    }
}
